<template>
  <div class="box">
    <el-row>
      <el-col :span="24">
        <div class="header">
          <el-form ref="form" :model="form" label-width="100px" class="flex">
            <el-form-item label="运单号" style="margin-left: 10px">
              <el-input v-model="dataParams.transportCode" placeholder="请输入运单号" style="width: 286px" />
            </el-form-item>
            <div style="margin-left: 10px; width: 386px">
              <el-form-item label="投诉">
                <datePick label="统计日期" @dataTime="handleDataTime" />
              </el-form-item>
            </div>
            <el-form-item label="投诉来源" style="margin-left: 10px">
              <selectList :key-name="'name'" :value="'请选择投诉来源'" :network-list="complainSourceList" @select="handleComplainSourceId" />
            </el-form-item>
            <el-form-item label="承包区" style="margin-left: 10px">
              <selectList :key-name="'networkName'" :value="'请选择承包区'" :network-list="chengbaoNameList" @select="handleContractAreaNameId" />
            </el-form-item>
            <el-form-item label="所属网点" style="margin-left: 10px">
              <networkSelect :value="'请选择所属网点'" @select="handleSelect" />
            </el-form-item>
            <el-form-item label="申诉状态" style="margin-left: 10px">
              <selectList :key-name="'name'" :value="'请选择申诉状态'" :network-list="explainStatusList" @select="handleExplainStatusId" />
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="onSubmit">查询</el-button>
              <!-- <el-button>重置</el-button> -->
            </el-form-item>
          </el-form>
        </div>
      </el-col>
    </el-row>

    <el-col v-if="!isObjectEmpty(tableObj)" type="flex" justify="space-between">
      <el-row>
        <el-col :span="6">
          <div>当前页共{{ tableObj.list.data.length }}项</div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <elltable :loading="loading" :data="tableObj.list.data" :th="tableObj.fields" :n="4" />
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="6">
          <pagination :page-size="dataParams.pageDate.pageSize" :total="tableObj.list.total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
        </el-col>
      </el-row>
    </el-col>
    <el-row v-if="isObjectEmpty(tableObj)" type="flex" justify="space-between">
      <el-col :span="24">
        <empty />
      </el-col></el-row>
    <!-- <div class="block" style="display: flex; justify-content: flex-end">

    </div> -->
  </div>
</template>
<script>
import datePick from '@/components/menuComponent/datePick.vue'
import networkSelect from '@/components/menuComponent/NetworkSelect.vue'
import selectList from '@/components/menuComponent/selectList.vue'
import timeExamine from '@/api/zhijian/time'
import empty from '@/components/menuComponent/empty.vue'
export default {
  components: {
    datePick,
    networkSelect,
    selectList,
    empty
  },
  data() {
    return {
      form: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        currentPage4: 4,
        desc: ''
      },
      loading: false,
      tableObj: {},
      dataParams: {
        complainSourceId: 0,
        contractAreaNameId: 0,
        endTime: '',
        explainStatusId: 0,
        networkNameId: 0,
        pageDate: {
          pageNum: 1,
          pageSize: 10
        },
        startTime: '',
        transportCode: ''
      },
      complainSourceList: [],
      chengbaoNameList: [],
      explainStatusList: []
    }
  },
  created() {
    this.$nextTick().then(() => {
      this.getComplainSource()
      console.log(this.tableObj)
    })
  },
  methods: {
    isObjectEmpty(obj) {
      return Object.keys(obj).length === 0
    },
    handleClick(tab, event) {
      console.log(tab, event)
    },
    handleDataTime(val) {
      this.dataParams.startTime = val[0]
      this.dataParams.endTime = val[1]
      console.log('val:', val)
      //   this.getTimeAll()
    },
    getComplainSource() {
      timeExamine.complainSource().then((res) => {
        if (res.code === 200) {
          this.complainSourceList = res.data
        }
        console.log('getComplainSource:', this.complainSourceList)
      })
      timeExamine.selectContractArea().then((res) => {
        if (res.code === 200) {
          this.chengbaoNameList = res.data || []
        }

        console.log('chengbaoNameList:', this.chengbaoNameList)
      })
      timeExamine.explainStatusAll().then((res) => {
        if (res.code === 200) {
          this.explainStatusList = res.data || []
        }
        console.log('explainStatusList:', this.explainStatusList)
      })
    },
    onSubmit() {
      if (this.dataParams.endTime === '' || this.dataParams.startTime === '') {
        this.$message('请选择投诉日期')
        return
      }
      if (this.dataParams.networkNameId === 0) {
        this.$message('请选择网点')
        return
      }
      this.loading = true
      timeExamine.falseSignSearch(this.dataParams).then((res) => {
        this.loading = false
        if (res.code === 200) {
          this.tableObj = res.data
        } else {
          this.tableObj = []
        }
        console.log('this.tableObj :', this.tableObj)
      })
      // console.log('提交')
      // console.log('输出参数：', this.dataParams)
    },
    handleSizeChange(val) {
      this.dataParams.pageDate.pageSize = val
      console.log('改变size', val)
    },
    handleCurrentChange(val) {
      this.dataParams.pageDate.pageNum = val
      console.log('改变页码', val, this.dataParams)
    },
    handleSelect(val) {
      this.dataParams.networkNameId = val
      console.log('select', val)
      //   this.getTimeAll()
    },
    handleComplainSourceId(val) {
      this.dataParams.complainSourceId = val
    },
    handleContractAreaNameId(val) {
      this.dataParams.contractAreaNameId = val
    },
    handleExplainStatusId(val) {
      this.dataParams.explainStatusId = val
    }
  }
}
</script>
<style lang="scss" scoped>
.box {
  padding: 0px 20px;
}

.flex {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
}

.flex-bettom {
  display: flex;
  justify-content: space-between;
}

.header {
  padding: 20px 0;
  border-bottom: 1px solid #ccc;
}

.el-row {
  margin-bottom: 20px;

  &:last-child {
    margin-bottom: 0;
  }
}

.el-col {
  border-radius: 4px;
}

.bg-purple-dark {
  background: #99a9bf;
}

.bg-purple {
  background: #d3dce6;
}

.bg-purple-light {
  background: #e5e9f2;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
}

.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
</style>
